package cn.tedu.medicalpath.base.response;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class JsonResult {
    @ApiModelProperty(value="状态码",required=true,example="2001")
    private Integer code;
    @ApiModelProperty(value="描述信息",required=true,example="操作成功!")
    private String message;
    @ApiModelProperty(value="响应数据")
    private Object data;

    public JsonResult(StatusCode statusCode) {
        this.code = statusCode.getCode();
        this.message = statusCode.getMessage();
    }

    public JsonResult(StatusCode statusCode, Object data) {
        this(statusCode);
        this.data = data;
    }

    public static JsonResult success(){
        return success(null);
    }

    public static JsonResult success(Object data){
        return new JsonResult(StatusCode.SUCCESS,data);
    }
}
